package cn.yujiago.shiro.domain;

import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Table;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

@Table(name = "sys_role")
public class RoleDO implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private String roleName;
    private String roleSign;
    private String remark;
    private Long userIdCreate;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp gmtCreate;
    private Timestamp gmtModified;

    private List<Long> menuIds;

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleSign() {
        return roleSign;
    }

    public void setRoleSign(String roleSign) {
        this.roleSign = roleSign;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getUserIdCreate() {
        return userIdCreate;
    }

    public void setUserIdCreate(Long userIdCreate) {
        this.userIdCreate = userIdCreate;
    }

    public Timestamp getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Timestamp gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public Timestamp getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Timestamp gmtModified) {
        this.gmtModified = gmtModified;
    }

    public List<Long> getMenuIds() {
        return menuIds;
    }

    public void setMenuIds(List<Long> menuIds) {
        this.menuIds = menuIds;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "RoleDO [id=" + id + ", roleName=" + roleName + ", roleSign=" + roleSign + ", remark=" + remark
                + ", userIdCreate=" + userIdCreate + ", gmtCreate=" + gmtCreate + ", gmtModified=" + gmtModified
                + ", menuIds=" + menuIds + "]";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RoleDO roleDO = (RoleDO) o;

        if (!id.equals(roleDO.id)) return false;
        if (!roleName.equals(roleDO.roleName)) return false;
        if (!roleSign.equals(roleDO.roleSign)) return false;
        if (remark != null ? !remark.equals(roleDO.remark) : roleDO.remark != null) return false;
        if (userIdCreate != null ? !userIdCreate.equals(roleDO.userIdCreate) : roleDO.userIdCreate != null)
            return false;
        if (gmtCreate != null ? !gmtCreate.equals(roleDO.gmtCreate) : roleDO.gmtCreate != null) return false;
        if (gmtModified != null ? !gmtModified.equals(roleDO.gmtModified) : roleDO.gmtModified != null) return false;
        return menuIds != null ? menuIds.equals(roleDO.menuIds) : roleDO.menuIds == null;
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + roleName.hashCode();
        result = 31 * result + roleSign.hashCode();
        result = 31 * result + (remark != null ? remark.hashCode() : 0);
        result = 31 * result + (userIdCreate != null ? userIdCreate.hashCode() : 0);
        result = 31 * result + (gmtCreate != null ? gmtCreate.hashCode() : 0);
        result = 31 * result + (gmtModified != null ? gmtModified.hashCode() : 0);
        result = 31 * result + (menuIds != null ? menuIds.hashCode() : 0);
        return result;
    }
}
